﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using EnvRide.Core.ObjectModel;
using CodeMadeSimple.Common.Tests;
using System.Xml;
using log4net.Core;

namespace EnvRide.Core.UnitTests
{
    public class OverrideTests : EnvRideBaseTest
    {
        public void Process(Override over)
        { 
            ExceptionAssert.AssertNullArgumentException("args", () => over.Process(null));

            XmlDocument doc = new XmlDocument();

            EnvRideProcessArguments args = new EnvRideProcessArguments { Document = doc };

            over.Xpath = "/root1";

            Assert.Throws<NullReferenceException>(() => over.Process(args), "The Environment property its null!");

            EnvRide.Core.ObjectModel.Environment env = Helper.CreateDummyEnvironment();

            over.Environment = env;

            over.Process(args);

            Assert.IsTrue(args.HasErrors);

            AssertContainsLoggedMessages(Level.Error, new[] { GetXPathDidNotReturnNodesMessage ("/root1") });                     
        }
    }
}
